<?php

namespace App\Http\Middleware;

use Illuminate\Routing\Middleware\ThrottleRequests;
use Symfony\Component\HttpFoundation\Response;
use Request;
use Validator;

class ThrottleCheck extends ThrottleRequests
{
    protected function buildResponse($key, $maxAttempts)
    {
        if(Request::isMethod('post')){
            exit(json_encode(['code'=>1,'msg'=>'请求频繁,请稍后重试']));
        }else{
            return redirect()->back()->withErrors(['throttle' => '请求过于频繁,请稍后重试']);
        }
    }
}
